﻿
#include "pch.h"

#include  "ortools/linear_solver/linear_solver.h"

using namespace operations_research;
void BasicExample()
{
	std::unique_ptr<operations_research::MPSolver> solver(operations_research::MPSolver::CreateSolver("GLOP"));
	operations_research::MPVariable* const x = solver->MakeNumVar(0.0, 1, "x");
	operations_research::MPVariable* const y = solver->MakeNumVar(0.0, 2, "y");

	LOG(INFO) << "Number of variables = " << solver->NumVariables();

	operations_research::MPConstraint* const ct = solver->MakeRowConstraint(0.0, 2.0, "ct");
	ct->SetCoefficient(x, 1.0);
	ct->SetCoefficient(y, 1.0);

	LOG(INFO) << "Number of constraints = " << solver->NumConstraints();

	operations_research::MPObjective* const objective = solver->MutableObjective();

	objective->SetCoefficient(x, 3.0);
	objective->SetCoefficient(y, 1.0);
	objective->SetMaximization();
	solver->Solve();
	LOG(INFO) << "Solution:" << std::endl;
	LOG(INFO) << "Objective value = " << objective->Value();
	LOG(INFO) << "x = " << x->solution_value();
	LOG(INFO) << "y = " << y->solution_value();

}

TEST(OrTools, First)
{
	BasicExample();
}

TEST(OrTools, LOG)
{
	LOG(INFO) << "log test ..";
}

